using System.Collections.Generic;

namespace Framework.Library.Core.Utils.Miscellaneous
{
    public class TestDataGetter : IDataGetter
    {
        private readonly IEnumerable<byte[]> _datas;
        private IEnumerator<byte[]> _dataEnumerator;
        private bool _disposed;

        public TestDataGetter(IEnumerable<byte[]> datas)
        {
            ValidationUtils.ArgumentNotNull(datas, "datas");

            _datas = datas;
        }

        #region IDataGetter Members

        public byte[] GetData()
        {
            if (_dataEnumerator == null)
                _dataEnumerator = _datas.GetEnumerator();

            if (!_disposed && _dataEnumerator.MoveNext())
                return _dataEnumerator.Current;
            else
                return null;
        }

        public void Dispose()
        {
            _disposed = true;
        }

        #endregion
    }
}